
<?php
require_once "../php/admin/dataSQL.php";
require_once "../php/admin/rootDB.php";
$adminDb=new rootDB();
date_default_timezone_set('PRC');
session_start();
if(isset($_SESSION['admin'])){
    $admin=$_SESSION['admin'];
   $currentpage=1;


    if(isset($_GET['page'])){
        $currentpage=$_GET['page'];
    }
    $dataAll=$adminDb->query_sign_all();
    $count=count($dataAll);
    $pagesize=6;
    $pages=ceil($count/$pagesize);
    $prepage=$currentpage-1;
    if($prepage<=0) {
        $prepage = 1;
    }
    $nextpage=$currentpage+1;
    if($nextpage>=$pages){
        $nextpage=$pages;

    }

    $start=($currentpage-1)*$pagesize;
    $data=$adminDb->query_sign_page($start,$pagesize);
    $sum=count($data);
}






else{
    echo "<script>window.location.href='../../index.php';</script>";

}



?>


<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>管理员列表</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="stylesheet" href="../static/css/font.css">
    <link rel="stylesheet" href="../static/css/xadmin.css">
    <script type="text/javascript" src="../static/js/jquery-3.3.1.min.js"></script>
    <script type="text/javascript" src="../static/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="../static/js/xadmin.js"></script>
</head>

<body>
<div class="x-nav">
      <span class="layui-breadcrumb">
        <a href="">首页</a>
        <a>
          <cite>站长管理员列表</cite></a>
      </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon" style="line-height:30px">ဂ</i></a>
</div>
<div class="x-body">

    <xblock>
        <span class="x-right" style="line-height:40px">共有数据：<?php echo $count ?> 条</span>
    </xblock>
    <table class="layui-table">
        <thead>
        <tr>
            <th>
                <div class="layui-unselect header layui-form-checkbox" lay-skin="primary"><i class="layui-icon">&#xe605;</i></div>
            </th>
            <th>ID</th>
            <th>姓名</th>
            <th>性别</th>
            <th>电话</th>
            <th>班级</th>
            <th>报名时间</th>
            <th>状态</th>
            <th>操作</th>
        </thead>
        <tbody>
        <?php






        for($i=0;$i<$sum;$i++) {
            $dat = $data[$i];
            $admin = $dat['user'];
            $id = $i + 1;
            $sex = $dat['sex'];
            $tel = $dat['tel'];
            $idd = $dat['id'];
            $major = $dat['major'];
            $time = $dat['addtime'];
        $examine=$dat['examine'];
            $time=date("Y-m-d H:i",$time);
            if ($examine === "200") {
                $examine="通过";
                echo " <tr><td>
                <div class=\"layui-unselect layui-form-checkbox\" lay-skin=\"primary\" data-id=$idd><i class=\"layui-icon\">&#xe605;</i></div>
            </td><td>$id</td>
            <td>$admin</td>
            <td>$sex</td>
            <td>$tel</td>
            <td>$major</td>
            <td>$time</td>
            <td>$examine</td>
            <td class=\"td-manage\">
                    <a href='show-student.php?id=$idd'>查看</a>
                <a title=\"删除\" onclick=\"member_del(this,'$idd')\" href=\"javascript:;\">
                    <i class=\"layui-icon\">&#xe640;</i>
                </a>
            </td></tr>";

            }
        }






        ?>
        </tbody>
    </table>
    <div class="page">
        <div>
            <a class="prev" href="<?php echo $_SERVER['PHP_SELF'].'?page='.$prepage; ?>">上一页</a>

            <span class="current"><?php echo $currentpage ?></span>
            <a class="num" href="<?php echo $_SERVER['PHP_SELF'].'?page='.$nextpage; ?>">下一页</a>
            <a class="next" href="<?php echo $_SERVER['PHP_SELF'].'?page='.$nextpage; ?>">&gt;&gt;</a>
            <a class="next" >共<?php echo $pages ?>页</a>
        </div>
    </div>

</div>
<script>
    layui.use('laydate', function(){
        var laydate = layui.laydate;

        //执行一个laydate实例
        laydate.render({
            elem: '#start' //指定元素
        });

        //执行一个laydate实例
        laydate.render({
            elem: '#end' //指定元素
        });
    });



    /*用户-删除*/
    function member_del(obj,id){
        layer.confirm('确认要删除吗？',function(index){
            //发异步删除数据
            $.ajax({
               type:'post',
               cache:'false',
               url:'../php/admin/dellidea.php',
               data:{
                   "id":id,
               },
                dataType:'json',
                success:function (dat) {
                    $(obj).parents("tr").remove();
                    layer.msg('已删除!',{icon:1,time:1000});
                },
                error:function () {
                    layer.msg('删除失败！',{icon:2,time:1000});
                }

            });


        });
    }

</script>
</html>